<?php

class index
{
public function index()
{
$root = array();
$root['return'] = 1;
$adv_list = $GLOBALS['cache']->get('MOBILE_INDEX_ADVS');
if($adv_list===false)
{
$advs = $GLOBALS['db']->getAll(' select * from '.DB_PREFIX."m_adv where page = 'index' and status = 1 order by sort desc ");
$adv_list = array();
foreach($advs as $k=>$v)
{
$adv_list[$k]['id'] = $v['id'];
$adv_list[$k]['name'] = $v['name'];
$adv_list[$k]['img'] =get_abs_img_root(get_spec_image($v['img'],640,240,1));
$adv_list[$k]['type'] = $v['type'];
$adv_list[$k]['data'] = $v['data'] = unserialize($v['data']);
if($v['type'] == 1)
{
$tag_count = count($v['data']['tags']);
$adv_list[$k]['data']['count'] = $tag_count;
}
if(in_array($v['type'],array(9,10,12,13))) 
{
if($v['type']==9||$v['type']==12||$v['type']==13) 
{
$adv_list[$k]['data']['cate_name'] = $GLOBALS['db']->getOne('select name from '.DB_PREFIX.'deal_cate where id = '.intval($v['data']['cate_id']));
}
elseif($v['type']==10)  
{
$adv_list[$k]['data']['cate_name'] = $GLOBALS['db']->getOne('select name from '.DB_PREFIX.'shop_cate where id = '.intval($v['data']['cate_id']));
}
$adv_list[$k]['data']['cate_name'] = $adv_list[$k]['data']['cate_name']?$adv_list[$k]['data']['cate_name']:'全部';
}
}
$GLOBALS['cache']->set('MOBILE_INDEX_ADVS',$adv_list);
}
$root['advs'] = $adv_list;
$indexs_list = $GLOBALS['cache']->get('MOBILE_INDEX_INDEX');
if($indexs_list===false)
{
$indexs = $GLOBALS['db']->getAll(' select * from '.DB_PREFIX.'m_index where status = 1 order by sort desc ');
$indexs_list = array();
foreach($indexs as $k=>$v)
{
$indexs_list[$k]['id'] = $v['id'];
$indexs_list[$k]['name'] = $v['name'];
$indexs_list[$k]['vice_name'] = $v['vice_name'];
$indexs_list[$k]['desc'] = $v['desc'];
$indexs_list[$k]['is_hot'] = $v['is_hot'];
$indexs_list[$k]['is_new'] = $v['is_new'];
$indexs_list[$k]['img'] = get_abs_img_root(get_spec_image($v['img'],640,120,1));
$indexs_list[$k]['type'] = $v['type'];
$indexs_list[$k]['data'] = $v['data'] = unserialize($v['data']);
if($v['type'] == 1)
{
$tag_count = count($v['data']['tags']);
$indexs_list[$k]['data']['count'] = $tag_count;
}
if(in_array($v['type'],array(9,10,12,13))) 
{
if($v['type']==9||$v['type']==12||$v['type']==13) 
{
$indexs_list[$k]['data']['cate_name'] = $GLOBALS['db']->getOne('select name from '.DB_PREFIX.'deal_cate where id = '.intval($v['data']['cate_id']));
}
elseif($v['type']==10)  
{
$indexs_list[$k]['data']['cate_name'] = $GLOBALS['db']->getOne('select name from '.DB_PREFIX.'shop_cate where id = '.intval($v['data']['cate_id']));
}
$indexs_list[$k]['data']['cate_name'] = $indexs_list[$k]['data']['cate_name']?$indexs_list[$k]['data']['cate_name']:'全部';
}
}
$GLOBALS['cache']->set('MOBILE_INDEX_INDEX',$indexs_list);
}
foreach($indexs_list as $key=>$value)
{
if(empty($indexs_list[$key]['data'])){
unset($indexs_list[$key]['data']);
}
}
$root['indexs'] = $indexs_list;
output($root);
}
}
?>